package leetcode;


import java.util.ArrayDeque;
import java.util.Deque;

/**
 * 用队列实现栈
 */
public class LeetCode225 {
    Deque<Integer> deque = new ArrayDeque<>();

    /**
     * Initialize your data structure here.
     */
    public LeetCode225() {

    }

    /**
     * Push element x onto stack.
     */
    public void push(int x) {
        deque.offer(x);
    }

    /**
     * Removes the element on top of the stack and returns that element.
     */
    public int pop() {
        return deque.pollFirst();
    }

    /**
     * Get the top element.
     */
    public int top() {
        return deque.peekLast();
    }

    /**
     * Returns whether the stack is empty.
     */
    public boolean empty() {
        return deque.isEmpty();
    }
}